//
//  ZHViewController.m
//  ZHPhoto
//
//  Created by Arthur on 09/24/2019.
//  Copyright (c) 2019 Arthur. All rights reserved.
//

#import "ZHViewController.h"
#import "ZHYPhoto.h"

@interface ZHViewController ()<CustomPhotoAlbumDelegate>

@end

@implementation ZHViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    
}

- (IBAction)buttonClick:(UIButton *)sender {
    
    if ([sender.titleLabel.text isEqualToString:@"启动相册"]) {
        [ZHYPhoto openPhotoWithChoseType:OpenPhotoTypeAlbum photoCount:5 andVC:self];
    } else {
        [ZHYPhoto openPhotoWithChoseType:OpenPhotoTypeCamera photoCount:5 andVC:self];
    }
    
    
}

// 已经选择的图片
- (void)CustomPhotoAlbumReceivePhotoArray:(NSMutableArray *)imageArray {
    
    NSLog(@"图片数量 **** %lu",(unsigned long)imageArray.count);
    
    int i = 0;
    for (NSString *imageStr in imageArray) {
        
        // 可以将base64字符串转为图片
        NSData *decodeData = [[NSData alloc] initWithBase64EncodedString:imageStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
        UIImage *decodedImage = [UIImage imageWithData: decodeData];
        
        // 将选择的图片显示
        UIImageView *imageView = [[UIImageView alloc] initWithImage:decodedImage];
        imageView.frame = CGRectMake(i*WIDTH/imageArray.count, 64, WIDTH/imageArray.count, 80);
        [self.view addSubview:imageView];
        i ++;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
